package com.view.Model;

import com.base.mvvm2.BasePresenterImpl2;
import com.face.gaoml.netlibrary.data.rusult.BaseSubscriber;
import com.face.gaoml.netlibrary.data.rusult.HttpResultFunc;
import com.modules.bean.User;
import com.view.SimpleAdapter2;
import com.view.multiple.ItemTyp1;
import com.view.multiple.ItemTyp2;
import com.base.recycleView.adapter.MultipleAdapter;

import java.util.ArrayList;

import javax.inject.Inject;

/**
 * Created by gml on 17/1/6.
 */

public class RecycleViewModle2 extends BasePresenterImpl2 {


//    private SimpleAdapter<User> tSimpleAdapter;
    private SimpleAdapter2 tSimpleAdapter;


//    @Inject  //1 构造函数 提供支援 提供对象     2.注入构造器所需要的参数的依赖 （ 注入传递）
//    public RecycleViewModle(SimpleAdapter<User> tSimpleAdapter) {
//        this.tSimpleAdapter = tSimpleAdapter;
//    }

    @Inject  //1 构造函数 提供支援 提供对象     2.注入构造器所需要的参数的依赖 （ 注入传递）
    public RecycleViewModle2(SimpleAdapter2 tSimpleAdapter) {
        this.tSimpleAdapter = tSimpleAdapter;

//        this.tSimpleAdapter.addItemView(new ItemTyp2());
    }

    public void findall() {
        mRxManager.addSubscription(
                apiStores.findall()
                        .map(new HttpResultFunc<ArrayList<User>>()),
                new BaseSubscriber<ArrayList<User>>() {
                    @Override
                    public void onNext(ArrayList<User> result) {
                        if (result != null) {

                            tSimpleAdapter.addAll(result);
//                            new MsgAlert().show(result.toString());
                        }
                    }
                }

        );
    }

//    public SimpleAdapter<User> gettSimpleAdapter() {
//        return tSimpleAdapter;
//    }


    public SimpleAdapter2 gettSimpleAdapter() {
        return tSimpleAdapter;
    }

}
